﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BomberManServer.Utils
{
    public class Graph<T>
    {
        public T[] data {get; private set;}
        public UInt32 width { get; private set; }
        public UInt32 height { get; private set; }

        public Graph(UInt32 width, UInt32 height)
        {
            this.width = width;
            this.height = height;
            data = new T[width * height];
        }

        // get object at (x,y)
        // MUST call check BEFORE
        public T at(UInt32 x, UInt32 y)
        {
            return data[x + y*width];
        }
        public T at(Coordinates coord)
        {
            return at(coord.xBlock, coord.yBlock);
        }

        // check if coordinates are valid
        public bool check(UInt32 x, UInt32 y)
        {
            return ( (x <= width) && (y <= height) );
        }
        public bool check(Coordinates coord)
        {
            return (check(coord.xBlock, coord.yBlock));
        }
        
        


    }
}
